// +build go1.7

package log

import (
	"runtime"
	"strings"

	"xp/lib/jsonx"
)

func writeCallers(pcs []uintptr, buf []byte) int {
	var i int
	frames := runtime.CallersFrames(pcs)
	for {
		f, more := frames.Next()
		index := strings.Index(f.File, "xp/")
		if index > 0 {
			if i != 0 {
				i += copy(buf[i:], ",")
			}
			i += copy(buf[i:], f.File[index+4:])
			i += copy(buf[i:], ":")
			i += jsonx.FormatBits(buf[i:], uint64(f.Line), f.Line < 0)
		}
		if !more {
			break
		}
	}
	return i
}
